﻿using System.ServiceModel;
using GA.Shared.Objects;
using System.Net;
using System.Collections.Generic;
using System.Net.Security;
using System;

namespace GA.Shared.Interfaces
{
    [ServiceContract(Name = "GAConnection", Namespace = "http://GA.Shared.Interfaces", ProtectionLevel = ProtectionLevel.EncryptAndSign)]
    public interface IConnection
    {
        /// <summary>
        /// Gets the IV Key for Authentication.
        /// </summary>
        /// <param name="ipAddress">IPAddress to pass over the information.</param>
        /// <returns>IV byte[] key</returns>
        [OperationContract]
        byte[] GetIV(IPAddress ipAddress);

        /// <summary>
        /// Gets the Key for Authentication.
        /// </summary>
        /// <returns>Key byte[]</returns>
        [OperationContract]
        byte[] GetKey();

        /// <summary>
        /// Authenticates a user using the provided encryption.
        /// </summary>
        /// <param name="authentication">Authentication information to send over the barrier.</param>
        /// <returns>User if authentication passed; otherwise, null.</returns>
        [OperationContract]
        object Authenticate(Authentication authentication);

        /// <summary>
        /// Creates a user using the provided encryption.
        /// </summary>
        /// <param name="authentication">Authentication information to send over the barrier.</param>
        /// <returns>User if creating the user was successful; otherwise, null.</returns>
        [OperationContract]
        SerializableTransferObject CreateUser(Authentication authentication);

        /// <summary>
        /// Creates an object of the specified type.
        /// </summary>
        /// <typeparam name="T">Type to search.</typeparam>
        /// <param name="authorizedUser">Authorized user to create the object.</param>
        /// <param name="newObject">Object to fix.</param>
        /// <returns>Object created.</returns>
        [OperationContract]
        SerializableTransferObject CreateObject(SerializableTransferObject authorizedUser, SerializableTransferObject newObject);

        /// <summary>
        /// Edits an object of the specified type.
        /// </summary>
        /// <typeparam name="T">Type to search.</typeparam>
        /// <param name="authorizedUser">Authorized user to create the object.</param>
        /// <param name="editObject">Object to fix.</param>
        [OperationContract]
        void EditObject(SerializableTransferObject authorizedUser, SerializableTransferObject editObject);

        /// <summary>
        /// Deletes an object of the specified type.
        /// </summary>
        /// <typeparam name="T">Type to search.</typeparam>
        /// <param name="authorizedUser">Authorized user to delete the object.</param>
        /// <param name="deleteObject">Object to fix.</param>
        [OperationContract]
        void DeleteObject(SerializableTransferObject authorizedUser, SerializableTransferObject deleteObject);

        /// <summary>
        /// Finds an object of the specified type.
        /// </summary>
        /// <param name="authorizedUser">Authorized user to delete the object.</param>
        /// <param name="parameters">Parameters to search.</param>
        /// <param name="type">Type to search.</param>
        /// <returns>LinkedDependencyObject found; otherwise, null.</returns>
        [OperationContract]
        SerializableTransferObject FindObject(SerializableTransferObject authorizedUser, string type, Dictionary<string, object> parameters);

        /// <summary>
        /// Finds objects of the specified type.
        /// </summary>
        /// <param name="authorizedUser">Authorized user to delete the object.</param>
        /// <param name="parameters">Parameters to search.</param>
        /// <param name="type">Type to search.</param>
        /// <returns>IEnumerable of LinkedDependencyObject found; otherwise, empty collection.</returns>
        [OperationContract]
        IEnumerable<SerializableTransferObject> FindObjects(SerializableTransferObject authorizedUser, string type, Dictionary<string, object> parameters);
    }
}
